<?php
class Admin_Model_Students
{
	public static function getList()
	{
		$st_obj = new Application_Model_Db_Students();
		$gr_obj = new Application_Model_Db_Groups();
		$temp = $st_obj->fetchAll();
	//	var_dump($temp->toArray());
		$select = $gr_obj->select();
		$out = array();
		foreach($temp as $row){
			
			$group = (array) $row->findParentRow('Application_Model_Db_Groups')->toArray();
			$row = $row->toArray();
		//	$group = $gr->toArray();
			//var_dump($select);
			$out[] = array_merge($row,array('group'=>$group['name']),array('json'=>json_encode($row)));
		}
		return $out;
	}
	public static function getGroupList()
	{
		$gr_obj = new Application_Model_Db_Groups();
		$temp = $gr_obj->fetchAll();
		$out = array();
		foreach ($temp as $row){
			$out[$row['group_id']]=$row['name'];
		}
		/*var_dump($out);
		die;*/
		return $out;
		
	}
	
	public static function addStudent($data)
	{
		$st_obj = new Application_Model_Db_Students();
		$st_obj->insert($data);
	}
	public static function editStudent($data,$id)
	{
		$st_obj = new Application_Model_Db_Students();
		$st_obj->update($data, 'student_id'.$id);
	}
}